import fetch from 'utils/fetch';


// 查看所有班级
export function classListData(provinceId, cityId, areaId, schoolId, ownerName, grade, className, classNum, page, rows) {
    const data = {
        provinceId, //省id
        cityId, //市id
        areaId, //区县id
        schoolId, //学校名称
        ownerName, //班主任姓名
        grade, //年级
        className, //班级名称
        classNum, //班级编号
        page,
        rows
    };
    return fetch({
        url: '/class/query',
        method: 'post',
        data,
    });
}

//添加班级
export function addClassInfo(creatorId, provinceId, cityId, areaId, schoolId, grade, number) {
    const data = {
        creatorId, //用户id
        provinceId, //省id
        cityId, //市id
        areaId, //区县id
        schoolId,
        grade, //年级
        number, //班级数量
    };
    return fetch({
        url: '/class/addClassInfo',
        method: 'post',
        data,
    });
}

//设置班主任
export function setOwner(classId, teacherId, teacherName) {
    const data = {
        classId,
        teacherId,
        teacherName
    };
    return fetch({
        url: '/class/setOwner',
        method: 'post',
        data
    });
}

//获取班主任列表
export function getOwnerList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/class/getOwnerList',
        method: 'post',
        data
    });
}

//班主任搜索
export function getTeacherLists(schoolId, ownerName) {
    const data = {
        schoolId,
        ownerName
    };
    return fetch({
        url: '/class/getTeacherList',
        method: 'post',
        data
    });
}

//用于设置班主任
export function getTeacherList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/class/getTeacherList',
        method: 'post',
        data
    });
}


//修改班昵称
export function changeClassName(classId, userId, className) {
    const data = {
        classId,
        userId,
        className
    };
    return fetch({
        url: '/class/changeClassName',
        method: 'post',
        data,
    });
}


//分页查询班级学生信息

export function findStudentClassInfosByPage(page, rows, classId) {
    const data = {
        classId
    };
    return fetch({
        url: `/classStudent/findStudentClassInfosByPage/${page}/${rows}`,
        method: 'post',
        data,
    });
}

//班级详情
export function getClassInfo(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/class/getClassInfo',
        method: 'post',
        data
    })
}

//2. 删除班级学生
export function removeStudent(studentClassMapIds) {
    const data = {
        studentClassMapIds
    };
    return fetch({
        url: '/shift/removeStudent',
        method: 'post',
        data,
    });
}

// 批量删除班级学生轮询接口
export function removeStudentProgress(timeStamp) {
    const data = {
        timeStamp
    };
    return fetch({
        url: '/shift/removeStudentProgress',
        method: 'post',
        data,
    });
}

//3. 离班(假删)
export function shiftStudent(studentClassMapIds) {
    const data = {
        studentClassMapIds
    };
    return fetch({
        url: '/shift/shiftStudent',
        method: 'post',
        data,
    });
}

//4. 导入班级学生
export function importStudent(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/shift/importStudent',
        method: 'post',
        data,
    });
}

// 批量导入学生轮询接口
export function importStudentProgress(timeStamp,classId) {
    const data = {
        timeStamp,
        classId
    };
    return fetch({
        url: '/shift/importStudentProgress',
        method: 'post',
        data,
    });
}

//  导入班级学生 数据校验接口
export function verifyStudentForImport(classId, filePath) {
    const data = {
        classId,
        filePath
    };
    return fetch({
        url: '/shift/verifyStudentForImport',
        method: 'post',
        data,
    });
}
//2. 获取班级信息
export function findClassInfoByClassId(classId) {
    const data = {
        classId
    };
    return fetch({
        url: `/classStudent/findClassInfoByClassId/${classId}`,
        method: 'post',
        data,
    });
}

//调班/集体调班
export function changeStudentClass(studentsId, fromClassId, toClassId, fromGradeId, toGradeId) {
    const data = {
        studentsId,
        fromClassId,
        toClassId,
        fromGradeId,
        toGradeId
    };
    return fetch({
        // url: '/classStudent/changeStudentClass', //edit by cuihd at 20180711 调班改为异步的
        url: '/changeStudentClass/changeStudentClass',
        method: 'post',
        data,
    });
}

// created by cuihd at 20180711 调班改为异步的
// 学生调班轮询接口
export function changeStudentClassProgress(timeStamp, fromClassId, toClassId) {
    const data = {
        timeStamp,
        fromClassId,
        toClassId
    };
    return fetch({
        url: '/changeStudentClass/changeStudentClassProgress',
        method: 'post',
        data,
    });
}

//8. 根据学校id获取年级列表
export function getGradeList(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/class/getGradeList',
        method: 'post',
        data,
    });
}

//删除班级
export function deleteClass(classId) {
    const data = {
        classId
    };
    return fetch({
        url: '/class/delete',
        method: 'post',
        data,
    });
}

//9. 条件查询学校列表
// export function getSchoolList(schoolName, provinceId, cityId, areaId) {
//     const data = {
//         schoolName,
//         provinceId,
//         cityId,
//         areaId
//     };
//     return fetch({
//         url: '/class/getSchoolList',
//         method: 'post',
//         data,
//     });
// }
// 查询学校
export function getSchoolList(schoolName,provinceId,cityId,areaId) {
    const data = {
        schoolName,
        provinceId,
        cityId,
        areaId
    };
    return fetch({
        url: '/school/querySchoolByName',
        method: 'post',
        data
    });
}

//10. 根据学校id查询年级列表
export function getGrade(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/class/getGradeList',
        method: 'post',
        data,
    });
}

//7. 获取班级编号
export function getClass(schoolId, grade) {
    const data = {
        schoolId,
        grade
    };
    return fetch({
        url: '/class/getClassNumList',
        method: 'post',
        data,
    });
}
//11. 根据年级和班级编号获取班级名称
export function getClassName(schoolId, grade, classNum, className) {
    const data = {
        schoolId,
        grade,
        classNum,
        className
    };
    return fetch({
        url: '/class/getClassName',
        method: 'post',
        data,
    });
}

//13. 开启/禁用群聊
export function groupChart(classId, status) {
    const data = {
        classId,
        status, //（0：禁用，1：启用）
    };
    return fetch({
        url: '/class/groupChart',
        method: 'post',
        data,
    });
}

//新增学生
export function addStudentIntoClass(studentName, studentSex, schoolRollCode, birth, phone, classId, schoolId, phones) {
    const data = {
        studentName,
        studentSex,
        schoolRollCode,
        birth,
        phone,
        classId,
        schoolId,
        phones
    };
    return fetch({
        url: '/classStudent/addStudentIntoClass',
        method: 'post',
        data,
    });
}